package com.wonder.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wonder.admin.domain.Material;
import com.wonder.admin.domain.SysPrdIn;
import com.wonder.admin.request.SysRoleRequest;
import com.wonder.admin.service.IMaterialService;
import com.wonder.common.common.AjaxResult;
import com.wonder.common.common.CommonPage;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

@Api(tags = "基础数据")
@RestController
@RequestMapping("/api/basic")
public class MaterialController {



    @Autowired
    private IMaterialService materialService;
    /**
     * 物料分页
     * @return
     */
    @RequestMapping(value = "/get_material_list",method = RequestMethod.POST)
    public AjaxResult<CommonPage<Material>> getMaterialList(@RequestBody SysRoleRequest sysRoleRequest){
        Page<Material> page = new Page<>(sysRoleRequest.getPage(),sysRoleRequest.getLimit());
        IPage<Material> list = materialService.selectList(sysRoleRequest,page);
        return AjaxResult.success(CommonPage.restPage(list));
    }

    /**
     * 同步金蝶物料信息
     */
    @PostMapping("/sync_material")
    public void  syncMaterial() throws Exception{

        materialService.syncMaterial();
    }
}
